package com.cn.aam.checaiduo.ui.me;

import android.content.Context;
import android.content.Intent;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;

import com.cn.aam.checaiduo.R;
import com.cn.aam.checaiduo.base.ToolBarManager;
import com.cn.aam.checaiduo.minterface.MyOnPageChangeListener;
import com.cn.aam.checaiduo.base.BaseActivity;
import com.cn.aam.checaiduo.ui.homepage.adapter.MyFragmentPageAdapter;
import com.cn.aam.checaiduo.ui.me.fragment.RechargeWithDrawRecordFragment;
import com.flyco.tablayout.SegmentTabLayout;
import com.flyco.tablayout.listener.OnTabSelectListener;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;

/**
 * monker on 2017/5/26.
 */

public class RechargeWithDrawRecordActivity extends BaseActivity {

    @BindView(R.id.tab_viewPager)
    ViewPager tabViewPager;

    @Override
    protected int layoutId() {
        return R.layout.activity_tab_viewpager;
    }

    public static Intent newInstance(Context context) {
        Intent intent = new Intent(context, RechargeWithDrawRecordActivity.class);
        return intent;
    }

    @Override
    protected void initView() {
        String[] titles = {"充值记录", "提现记录"};
        List<Fragment> fragments = new ArrayList<>();
        final SegmentTabLayout mSegmentTabLayout = ToolBarManager.with(this, WMContent)
                .setNavigationIcon(R.drawable.ic_nav_arrow_back)
                .setBackgroundColor(R.color.toolbar_bg_grey)
                .setTabContent(titles).getTab();

        fragments.add(RechargeWithDrawRecordFragment.newInstance(RechargeWithDrawRecordFragment.RECHAR));
        fragments.add(RechargeWithDrawRecordFragment.newInstance(RechargeWithDrawRecordFragment.WITHDRAW));

        tabViewPager.setAdapter(new MyFragmentPageAdapter(getSupportFragmentManager(), fragments));


        mSegmentTabLayout.setOnTabSelectListener(new OnTabSelectListener() {
            @Override
            public void onTabSelect(int position) {
                tabViewPager.setCurrentItem(position);
            }

            @Override
            public void onTabReselect(int position) {

            }
        });

        tabViewPager.addOnPageChangeListener(new MyOnPageChangeListener() {
            @Override
            public void onPageSelected(int position) {
                mSegmentTabLayout.setCurrentTab(position);
            }
        });

    }
}
